package com.game.centerserver.infrastructure.service.impl;

import com.game.centerserver.infrastructure.entity.DstClusterIni;
import com.game.centerserver.infrastructure.dao.DstClusterIniDao;
import com.game.centerserver.infrastructure.service.DstClusterIniService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * (DstClusterIni)表服务实现类
 *
 * @author makejava
 * @since 2024-11-10 17:15:12
 */
@Service("dstClusterIniService")
public class DstClusterIniServiceImpl implements DstClusterIniService {
    @Resource
    private DstClusterIniDao dstClusterIniDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DstClusterIni queryById(Integer id) {
        return this.dstClusterIniDao.queryById(id);
    }

    @Override
    public DstClusterIni queryByArchiveId(String archiveId) {
        return dstClusterIniDao.queryByArchiveId(archiveId);
    }

    /**
     * 新增数据
     *
     * @param dstClusterIni 实例对象
     * @return 实例对象
     */
    @Override
    public boolean insert(DstClusterIni dstClusterIni) {
        DstClusterIni dstClusterIni1 = dstClusterIniDao.queryByArchiveId(dstClusterIni.getArchiveId());
        if(dstClusterIni1 != null){
            return false;
        }
        return this.dstClusterIniDao.insert(dstClusterIni) > 0;
    }

    /**
     * 修改数据
     *
     * @param dstClusterIni 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(DstClusterIni dstClusterIni) {
        return this.dstClusterIniDao.update(dstClusterIni) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.dstClusterIniDao.deleteById(id) > 0;
    }

    @Override
    public boolean deleteByArchiveId(String archiveId) {
        return dstClusterIniDao.deleteByArchiveId(archiveId) > 0;
    }
}
